$(function(){
    var url = location.href.split("?")[1];
    console.log(url);
    var id = location.href.split("?")[1].split("&")[3]
    var productImg = location.href.split("?")[1].split("&")[1] ;
    var productName = location.href.split("?")[1].split("&")[2] ;
    // console.log(str);
    var productImg = decodeURI(productImg);
    var productName = decodeURI(productName);
    // console.log(productImg);
    
    
    
    
    
    $.ajax({
        type:'get',
        url:"http://193.112.55.79:9090/api/getproductcom?"+url,
        success:function(res){
            var data = res.result;
            data['productImg'] = productImg;
            data['productName']=productName;
            var comment_datail = template("comment_datail",{
                "data":data
            })
            var comment_data = template("comment_data",{
                "data":data
            })
            console.log(data);
            $(".comment_datail").html(comment_datail);
            $(".comment_data").html(comment_data);
        }
        
    })

    //  获取到当前的id传给跳转到的页面
    $('.btn_x').on('tap',function(){
        $(this).attr("href","product.html?"+id);
    })
    $('.btn_q').on('tap',function(){
        $(this).attr("href","brand.html?"+id);
    })
    
    var btn = document.querySelector(".btn_R");
    btn.onclick = function(){
        location.reload();
    }
        
})